package com.aiyige.page.detail.adpater;

import android.view.View;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.selectregion.model.HeaderRegionItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2017/10/26.
 */

public class DetailHeaderAdapter extends BaseQuickAdapter<HeaderRegionItem, DetailHeaderAdapter.SelectRegionHeaderViewHolder> {

    public DetailHeaderAdapter() {
        super(R.layout.detail_header, new LinkedList<HeaderRegionItem>());
    }

    @Override
    protected void convert(SelectRegionHeaderViewHolder helper, HeaderRegionItem item) {
        helper.bindData(item);
    }

    public static class SelectRegionHeaderViewHolder extends BaseViewHolder {
        @BindView(R.id.itemTv)
        TextView itemTv;

        public SelectRegionHeaderViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(HeaderRegionItem item) {
            switch (item.getType()) {
                case HeaderRegionItem.TYPE_FAILED:
                    itemTv.setText(R.string.retry);
                    break;
                case HeaderRegionItem.TYPE_SUCCEED:
                    itemTv.setText(item.getName());
                    break;
                case HeaderRegionItem.TYPE_LOCALIZING:
                    itemTv.setText(R.string.localizing_now);
                    break;
            }
        }
    }
}
